package site.assad.service;

import org.springframework.stereotype.Service;

import java.util.Random;

/**
 * Author: Al-assad 余林颖
 * E-mail: yulinying_1994@outlook.com
 * Date: 2018/1/10 11:50
 * Description: 模拟 PM2.5 数据获取的业务层
 */
@Service
public class PMService {

    private Random random = new Random();

    //模拟从数据库或从其他服务中获取城市 PM2.5 AQI 数据；
    public String getData(String city){
        if(city.equals("bj")){
            return "Beijing AQI: "+ ((random.nextBoolean()?1:-1) * random.nextInt(10) + 40);
        }else if(city.equals("gz")){
            return "Guangzhou AOI: " + ((random.nextBoolean()?1:-1) * random.nextInt(10) + 20);
        }else{
            return "Unknown city";
        }
    }

}
